home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 176-200 / disk_179 / excption / excption.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  5KB  |  118 lines

  1. /**************************************************************************/
  2. /*                                                                        */
  3. /*                EXCEPTION HANDLER / CHIP STACK                          */
  4. /*               ==========================================               */
  5. /*                                                                        */
  6. /*                                                                        */
  7. /*  MODULE      : Exception                                               */
  8. /*  NOM         : Exception.h                                             */
  9. /*  FONCTION    :                                                         */
  10. /*                                                                        */
  11. /*  RESPONSABLE : HEWES Gerald                                            */
  12. /*  TEL         : 33 (1) 46 24 20 27                                      */
  13. /*                                                                        */
  14. /**************************************************************************/
  15.  
  16. /**************************************************************************/
  17. /*                                                                        */
  18. /* HEW 880310 Ver 0.1 : First Soft Version                                */
  19. /* HEW 880324 Ver 0.2 : Handle 68000 exceptions                           */
  20. /* HEW 880413 Ver 0.3 : Handle 680X0 Formats                              */
  21. /* HEW 880508 Ver 0.4 : First Released version : routines split           */
  22. /*                      Major name changes for better homogeneity         */
  23. /* HEW 880517 Ver 0.5 : include change. No more puts in library           */
  24. /* HEW 880605 Ver 0.6 : Disable/Enable Function + Prototypes              */
  25. /*                                                                        */
  26. /**************************************************************************/
  27.  
  28.  
  29. #ifndef E_EXCEPTION_H
  30. #define E_EXCEPTION_H
  31.  
  32. typedef int   ExcpClass;
  33.  
  34. #include <setjmp.h>
  35. #include "local:private/excppriv.h"
  36.  
  37. /*********** PREDEFINED  EXCEPTION CLASSES 0-2047 ************************/
  38.  
  39.                 /************************************************/
  40.                 /*  All Values from 0-65535 are reserved and    */
  41.                 /*  should not be used by application programs  */
  42.                 /*  Since the class is an unsigned int that     */
  43.                 /*  still leaves 2**32-2*8 different values     */
  44.                 /*  That should satisfy every applications      */
  45.                 /*  Values 0-31 are resserved for trap          */
  46.                 /*  Handling.                                   */
  47.                 /************************************************/
  48.  
  49. #define  BUS_ERROR           2
  50. #define  ADDRESS_ERROR       3
  51. #define  ILLEGAL_INSTRUCTION 4
  52. #define  ZERO_DIVIDE         5
  53. #define  CHK_EXCP            6
  54. #define  TRAPV_EXCP          7
  55. #define  PRIVILEGE_ERROR     8
  56. #define  TRACE               9
  57. #define  EMUL1010           10
  58. #define  EMUL1111           11
  59.  
  60.  
  61. #define  NUMERIC_ERROR    1025
  62. #define  CONSTRAINT_ERROR 1026
  63. #define  STORAGE_ERROR    1027
  64. #define  TASKING_ERROR    1028
  65. #define  IO_READ_ERROR    1029
  66. #define  IO_WRITE_ERROR   1030
  67. #define  IO_ERROR         1031
  68. #define  ABORT_ON_CTRLC   1032
  69. #define  ABORT_ON_CTRLD   1033
  70.  
  71. /***************************** Functions *********************************/
  72.  
  73. extern void      EIRaise(E_ErrorStatus *,ExcpClass) ;
  74. extern void      EIBlow(E_ErrorStatus *,ExcpClass)  ;
  75. extern ExcpClass AllocException(ExcpClass)          ;
  76. extern void      FreeException(ExcpClass)           ;
  77. extern void      EIInit(E_ErrorStatus *)            ;
  78. extern void      EIExcpHandler()                    ;
  79. extern void      EIUnmount(E_ErrorStatus *)         ;
  80. extern void      ExcpDisable(E_ErrorStatus *)       ;
  81. extern void      ExcpEnable(E_ErrorStatus *)        ;
  82.  
  83. /***************************** Macros    *********************************/
  84.  
  85. #define ExcpDeclare struct E_S_ERRORLINK E_buffer
  86.  
  87. #define ExcpGlobal  E_ErrorStatus E_global;\
  88.                     ExcpClass E_excpfree=65536
  89.  
  90. #define BEGIN  E_buffer.E_pred = E_global.E_up;\
  91. E_global.E_up = &E_buffer;E_buffer.E_state = E_PROTECTED;\
  92. E_buffer.E_magic = EM_MAGIC;\
  93. if((E_buffer.E_number = setjmp(E_buffer.E_current))==0)
  94.  
  95. #define EXCEPTION else
  96.  
  97. #define END E_global.E_up = E_buffer.E_pred;
  98.  
  99. #define MAIN EIInit(&E_global);\
  100. if((E_global.E_top.E_number = setjmp(E_global.E_top.E_current))==0)
  101.  
  102. #define OUT EIUnmount(&E_global);
  103.  
  104. #define Eclass E_global.E_up->E_number
  105.  
  106. #define RAISE(number) EIRaise(&E_global,number)
  107. #define BLOW(number)  EIBlow(&E_global,number)
  108.  
  109.         /*   ---------- V 0.6 ----------  */
  110.  
  111. #define EXCPENABLE   ExcpEnable(&E_global)
  112. #define EXCPDISABLE  ExcpDisable(&E_global)
  113.  
  114. #endif
  115.  
  116. /*************************  CIVILISATION ENDS HERE  ***********************/
  117.  
  118.